package cn.cms.listener;

import cn.cms.webcommon.LocalContextFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class ContainerStartListener implements ServletContextListener {

    @Override
    public void contextInitialized(ServletContextEvent ctx) {
        WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(ctx.getServletContext());
        LocalContextFactory.getInstance().setSpringWebContext(applicationContext);
    }

    @Override
    public void contextDestroyed(ServletContextEvent arg0) {

    }

}
